package com.techblor.wechat.library.config;

import com.techblor.wechat.library.api.*;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * 微信接口注册
 */
@Configuration
@ConditionalOnClass({WechatRegistry.class})
@EnableConfigurationProperties(WechatProperties.class)
@ConditionalOnProperty(prefix = "wechat", name = "enable", matchIfMissing = true)
public class WechatRegistry {

    @Autowired
    private WechatProperties wechatProperties;

    @Bean
    public TokenApi tokenApi() {
        return new TokenApi();
    }

    @Bean
    public SnsApi snsApi() {
        return new SnsApi(wechatProperties);
    }

    @Bean
    public UserApi userApi() {
        return new UserApi();
    }

    @Bean
    public MessageApi messageApi() {
        return new MessageApi();
    }

    @Bean
    public Qyapi qyapi() {
        return new Qyapi();
    }

    @Bean
    public TicketApi ticketApi() {
        return new TicketApi();
    }

	@Bean
    public WxacodeApi wxacodeApi() {
        return new WxacodeApi();
    }

}
